package cn.nexd.location.collector;


import android.content.Context;

import cn.nexd.location.NexdLocationConfig;
import cn.nexd.location.collector.core.Collector;

/**
 * 采集系统对外提供服务的类.
 * Created by codingfish on 15/9/28.
 */
public final class NexdCollectorAgent {


    private CollectorDispatcher collectorDispatcher;
    private Collector.BluetoothCollectorListener bluetoothCollectorListener;

    private NexdCollectorAgent() {
        collectorDispatcher = new CollectorDispatcher();
    }

    public static NexdCollectorAgent getCollectorAgent() {
        return NexdCollectorAgentClassHolder.NEXD_COLLECTOR_AGENT;
    }

    private static class NexdCollectorAgentClassHolder {
        public static final NexdCollectorAgent NEXD_COLLECTOR_AGENT = new NexdCollectorAgent();
    }


    /**
     * 设置上下文对象。
     *
     * @param context 当前上下文对象
     */
    public void setContext(Context context) {
        collectorDispatcher.setContext(context);
    }

    /**
     * 设置 Collector 的配置对象。
     *
     * @param config
     * @see NexdLocationConfig
     */
    public void setCollectorConfig(NexdCollectorConfig config) {
        collectorDispatcher.setCollectorConfig(config);
    }


    /**
     * 设置 Wifi 采集器监听。
     *
     * @param wifiCollectorListener
     */
    public void setWifiCollectorListener(Collector.WifiCollectorListener wifiCollectorListener) {
        collectorDispatcher.setWifiCollectorListener(wifiCollectorListener);
    }

    /**
     * 设置蓝牙采集器监听.
     *
     * @param bluetoothCollectorListener
     */
    public void setBluetoothCollectorListener(Collector.BluetoothCollectorListener bluetoothCollectorListener) {
        collectorDispatcher.setBluetoothCollectorListener(bluetoothCollectorListener);
    }

    /**
     * 开启采集器。
     */
    public void startCollector() {
        collectorDispatcher.startCollector();
    }

    /**
     * 停止采集器。
     */
    public void stopCollector() {
        collectorDispatcher.stopCollector();
    }

    public void destroyCollector() {
        collectorDispatcher.destroyCollector();
    }
}

